<%@ page contentType="text/html; charset=UTF-8" buffer="16kb"%>
<%@ include file="../include/taglib.jsp"%>
<%
    response.setHeader("Cache-Control", "no-store");
    response.setHeader("Pragrma", "no-cache");
    response.setDateHeader("Expires", 0);
    Long resid = Long.parseLong(request.getParameter("id"));
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>linux综合性能页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta name="Keywords" content=" " />
<meta name="Description" content=" " />
<%@ include file="../include/common.jsp"%>

<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/sub_menu.css" />
<link rel="stylesheet" type="text/css"
	href="${pageContext.request.contextPath}/style/default/bsm/perf/listPage.css" />
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.js"></script>
	
<script type="text/javascript"
	src="${pageContext.request.contextPath}/resources/charts/FusionCharts.jqueryplugin.js"></script>
	
<script type="text/javascript"
	src="${pageContext.request.contextPath}/js/common/Xslider.js"></script>
	

<script type="text/javascript">

	
	//全局请求处理
    var requestChart;
	function initRequest(){
		if(typeof requestChart == undefined || requestChart==null){
			requestChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/MSSpline.swf?ChartNoDataText=没有数据","requestChart1", "100%", "150px", "0", "1" );
		}
		$.ajax({
			url : 'real-time!childResList.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				childType:'1203050100000'
			},
			success : function(data) { //
				$('#managelistwraper > .videolist ul ').remove('li');
				$.each(data.res,function(i,index){
					$('#managelistwraper > .videolist ul ').append('<li><span id='+index.id+' class="listspan">'+index.name+'</span> </li>');
				});		
				//最多显示三个   一次移动两个   不可循环   垂直滚动
				$("#managelistwraper").Xslider({
					unitdisplayed : 4,
					numtoMove : 2,
					loop : "cycle",
					dir : "V"
				});
				//给每一列加点击操作
				$('#managelistwraper .videolist ul li').click(function(){
					$(this).addClass('liselected').siblings().removeClass('liselected');
					
					$.ajax({
						url : 'real-time!get2LineChart.action', // 
						type : 'POST',
						dataType : "json",
						data : {
							resId :$(this).children('span').attr('id'),
							propIds:'120305010000001,120305010000002'
						},
						success : function(dataset) {
							requestChart.setJSONData(dataset);
							requestChart.render("managechartdiv");
						}
					});
				});
				
				//触发第一个
				$('#managelistwraper .videolist ul li :first').click();
			}
		});
	}
	
	var memPoolCol;
	function memPool(){
		if(typeof memPoolCol == undefined || memPoolCol == null){
			memPoolCol =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf?ChartNoDataText=没有数据","memPoolCol1", "100%", "150", "0", "1" );
		}
		$.ajax({
			url : 'real-time!get2ColumnChart.action', // 
			type : 'POST',
			dataType : "json",
			data : {
				resId :<%=resid %>,
				detail:1,
				childType:'1203050500000',
				propIds:'120305050000005',
				unit:'',
				top:'10'
			},
			success : function(data) {
				memPoolCol.setJSONData(data);
				memPoolCol.render("memPoolDiv");
			}
		});
	}
	
	
	var uptimeColChart;
	var heapChart;
	var cachehitCol;
	var cacheRateCol;
	function initBaseInfo(){
	       
			
			//基本信息
			$.ajax({
				url : 'real-time!getBaseInfo.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					propIds:'prop_110305000000013,attr_110305000000001,prop_110305000000014,prop_110305000000017,prop_110305000000005,prop_110305000000007,prop_110305000000002'
				},
				success : function(data) {
					$('#prop_110305000000013').text(data.prop_110305000000013); 
					$('#attr_110305000000001').text(data.attr_110305000000001); 
					$('#prop_110305000000014').text(data.prop_110305000000014); 
					$('#prop_110305000000017').text(data.prop_110305000000017); 
					$('#prop_110305000000005').text(data.prop_110305000000005); 
					$('#prop_110305000000007').text(data.prop_110305000000007); 
					$('#prop_110305000000002').text(data.prop_110305000000002); 
					$('#resIp').text(data.ip);
				}
			});
			
			 //平均负载柱图
			$.ajax({
				url : 'real-time!get2ColumnPropChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1203050400000',
					propIds:'120305040000003,120305040000002,120305040000001',
					namealias:'池最多个数,池最少个数,池化线程数量'
				},
				success : function(data) {
					if(typeof uptimeColChart == undefined || uptimeColChart == null){
						 uptimeColChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","uptimeColChart11", "100%", "130", "0", "1" );
					}
					uptimeColChart.setJSONData(data);
					uptimeColChart.render("threadChart");
				}
			});
			
			//事件回滚率
			$.ajax({
				url : 'real-time!getHLineGauge.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					childType:'1203050200000',
					maxPropId:'100',
					usePropId:'120305020000005',
					unit:'%'
				},
				success : function(data) {
					if(typeof heapChart == undefined || heapChart == null){
						heapChart =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/HLinearGauge.swf?ChartNoDataText=没有数据","heapChart1", "100%", "130", "0", "1" );
					}
					heapChart.setJSONData(data);
					heapChart.render("jtaRateCol");
				}
			});
			
			//web 调用次数
			if(typeof cacheRateCol == undefined || cacheRateCol == null){
				cacheRateCol =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","cacheRateCol1", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1203050600000',
					propIds:'120305060000002',
					unit:'',
					top:'5'
				},
				success : function(data) {
					cacheRateCol.setJSONData(data);
					cacheRateCol.render("webCol");
				}
			});
			
			//连接池使用率
			if(typeof cachehitCol == undefined || cachehitCol == null){
				cachehitCol =  new FusionCharts( "${pageContext.request.contextPath}/resources/charts/Column2D.swf","cachehitCol1", "100%", "130", "0", "1" );
			}
			$.ajax({
				url : 'real-time!get2ColumnChart.action', // 
				type : 'POST',
				dataType : "json",
				data : {
					resId :<%=resid %>,
					detail:1,
					childType:'1203050300000',
					propIds:'120305030000008',
					unit:'%',
					top:'5'
				},
				success : function(data) {
					cachehitCol.setJSONData(data);
					cachehitCol.render("connRate");
				}
			});
	}
	
	$(document).ready(function() {
			initBaseInfo();
			memPool();
			
			initRequest();
		//CPU 内存 每10S刷新一次
		setInterval('initBaseInfo()',60000);
		
	});
</script>

</head>
<body>

	<div class="column">
		<div class="col-main">
			<!--基本信息-->
			<div class="col-l-extra h-400">
			<h2 class="title-h2 m-0">基本信息</h2>
			<ul class="col-l-ul">
					<li><span class="col-l-ul-l" >中间件类别:</span><span 
								class="col-l-ul-r"><img src="${pageContext.request.contextPath}/style/default/bsm/perf/images/jboss24_24.gif"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">IP:</span><span id="resIp"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">版本:</span><span id="prop_110305000000013"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">端口:</span><span id="attr_110305000000001"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">java版本:</span><span id="prop_110305000000014"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">java虚拟机版本:</span><span id="prop_110305000000017"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">最大内存:</span><span id="prop_110305000000005"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">空闲内存:</span><span id="prop_110305000000007"
						class="col-l-ul-r"></span>
					</li>
					<li><span class="col-l-ul-l" class="baseinfo">服务启动时间:</span><span id="prop_110305000000002"
						class="col-l-ul-r"></span>
					</li>
			</ul>
			</div>
			<!--@end基本信息-->
			<div class="col-r-main">
				<div class="col-v-rate-extra" >
				<h2 class="title-h2 m-0">连接池使用率  TOP5</h2>
					<div id="connRate"></div>
				</div>
				<!--@end基本信息-->
				<div class="col-v-rate-extra f-r">
				<h2 class="title-h2 m-0">线程数量</h2>
				   <div id="threadChart"></div>
			    </div>
			    
			     <div class="col-v-rate-extra">
		            <h2 class="title-h2 m-0">WEB调用次数 TOP5</h2>
			       <div id="webCol"></div>
			    </div>
			    
				<div class="col-v-rate-extra f-r">
				<h2 class="title-h2 m-0">事务回滚率</h2>
				   <div id="jtaRateCol"></div>
			    </div>
		 </div>   
	  </div>
	</div>
	
		<div class="column b-1">
		  <h2 class="title-h2 m-0">Servlet请求数量 TOP10</h2>
		  <div class="col-r-main h-150" style="width:100%;">
	           <div id="memPoolDiv"></div>
		  </div>
		</div>
		
		<div class="column b-1">
						<h2 class="title-h2 m-0">管理器子资源 [当天趋势图]-[会话总量,活动会话数]</h2>
							<div class="col-l-extra"  style="width:20%">
							<ul class="col-l-ul">
								<div id="managelistwraper">
								 <a class="abtn aright" href="#down"></a>
									<div class="videolist">
										<ul>
										</ul>
									</div>
									<a class="abtn aleft" href="#up" ></a>
								</div>
							</ul>
						</div>
					    <div class="col-net-main p-75">
						    <div id="managechartdiv"></div>
					    </div>
	     </div>
		
	    <div class="column " style="width:100%;height:5px;"></div>
</body>